package API.Class.game;

//导入包
//猜数字，值为0~1000

import java.util.Random;

public class Main {// 声明类

    // 创建成员变量
    private boolean first;
    private int max;
    private int min;
    public int times;
    private int Size;

    public Main() {
        Random ran = new Random();
        max = 1000;
        min = 0;
        times = -1;
        Size = ran.nextInt(501) + ran.nextInt(500);
    }

    //如果输出值为Done则代表执行完成
    //think为用户猜的数
    public String Start(int think) {
        first = true;
        if (start(think))
            return "Done";
        else {
            return "提示：值在" + min + "~" + max + "之间";
        }
    }

    private boolean start(int think) {
        // 条件判断句
        if ((Size) != think) {
            if (think > Size) {
                if (think < max) {
                    max = think;
                }
            } else {
                if (think > min) {
                    min = think;
                }
            }
        } else {
            return true;
        }
        return false;

    }

    public static String GetTime(long beginTime, long endTime) {
        long subtracttime = (endTime - beginTime) / 1000;
        long minutes = 0;
        long seconds = 0;
        if (subtracttime >= 60) {
            minutes = subtracttime / 60;
            seconds = subtracttime - minutes * 60;
        } else {
            seconds = subtracttime;
        }
        // 输出总耗时
        return minutes + "分" + seconds + "秒";
    }
}